import request from '@/router/axios'
import { baseUrl } from '@/config/env'

// export const login = (params) => request({
//   url: 'oauth/token',
//   method: 'POST',
//   headers: {
//     'Content-Type': 'application/x-www-form-urlencoded',
//     Authorization: 'Basic c2VydmljZToxMjM='
//   },
//   meta: {
//     isToken: false
//   },
//   data: {
//     username: params.username,
//     password: params.password,
//     grant_type: 'password'
//   }
// })

export const login = (params) => request({
  url: 'oauth/login/password',
  method: 'POST',
  meta: {
    isToken: false
  },
  data: params
})

export const getUserInfo = () => request({
  url: 'api/current/user/info',
  method: 'get'
})

export const refeshToken = () => request({
  url: baseUrl + '/user/refesh',
  method: 'post'
})

export const getMenu = (param) => request({
  url: 'api/current/user/authority',
  method: 'get',
  data: param
})

export const getTopMenu = () => request({
  url: 'api/current/user/topMenu',
  method: 'get'
})

export const menuById = (params) => request({
  url: 'api/current/user/menuById',
  method: 'get',
  params
})

export const sendLogs = (list) => request({
  url: baseUrl + '/user/logout',
  method: 'post',
  data: list
})

export const logout = () => request({
  url: 'oauth/logout',
  method: 'GET'
})
